package com.weixing.mall.provider.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.provider.api.model.vo.SysDictVo;
import com.weixing.mall.provider.api.service.SysDictRPC;
import com.weixing.mall.provider.mapper.FeedbackMapper;
import com.weixing.mall.provider.model.domain.Feedback;
import com.weixing.mall.provider.model.query.FeedbackQuery;
import com.weixing.mall.provider.model.vo.FeedbackTypeVo;
import com.weixing.mall.provider.model.vo.FeedbackVo;
import com.weixing.mall.provider.service.IFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 会员模块-用户反馈表 服务实现类
 * </p>
 *
 * @author Small
 * @since 2019-11-13
 */
@Service
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, Feedback> implements IFeedbackService {

    @Autowired
    private SysDictRPC sysDictRPC;

    @Override
    public IPage<FeedbackVo> selectList(Page page, FeedbackQuery feedbackQuery) {
        return baseMapper.selectVoList(page,feedbackQuery);
    }

    @Override
    public FeedbackVo selectDetail(Long id) {
        return baseMapper.selectDetail(id);
    }

    @Override
    public  List<FeedbackTypeVo> getFeedBackType() {
        List<SysDictVo> sysDictVoList = sysDictRPC.getDictByCode("FeedbackCategories").getData();
        List<FeedbackTypeVo> feedbackTypeVoList = new ArrayList<>();
        System.out.println(sysDictVoList);
        if(sysDictVoList.size()>0){
            for(int i = 0;i<sysDictVoList.size();i++){
               SysDictVo sysDictVo = sysDictVoList.get(i);
                FeedbackTypeVo feedbackTypeVo = new FeedbackTypeVo();
                if(sysDictVo!=null){
                    feedbackTypeVo.setValue(sysDictVo.getDictValue());
                    feedbackTypeVo.setDesp(sysDictVo.getDictValueDesp());
                }
                feedbackTypeVoList.add(feedbackTypeVo);
            }
        }
        return feedbackTypeVoList;
    }
}
